import { D3Element } from '../../types';

const icons: Record<string, string> = {
  edit: 'M818.77 256L646.2 106.67a64 64 0 00-91.52 6.61L78.29 685.87A64 64 0 0064 725.33l-2.56 198.4a32.21 32.21 0 0031.79 32.43l186.45 1.5a64 64 0 0049.28-21.34L825.39 345.6a64 64 0 00-6.62-89.6zM270.08 872.96l-123.1-1.07 2.35-137.17 457.39-549.97 139.95 121.38zm238.08.21H928q32 0 32 32v21.34q0 32-32 32H508.16q-32 0-32-32v-21.34q0-32 32-32z',
  plus: 'M863.79 469.12H554.67V160c0-17.7-14.3-32-32-32h-21.34c-17.7 0-32 14.3-32 32v309.12H160.21c-17.7 0-32 14.3-32 32v21.33c0 17.71 14.3 32 32 32h309.12v309.12c0 17.71 14.3 32 32 32h21.34c17.7 0 32-14.29 32-32V554.45h309.12c17.7 0 32-14.29 32-32v-21.33c0-17.7-14.3-32-32-32z',
  delete:
    'M929.92 192h-832a32 32 0 00-32 32v21.33a32 32 0 0032.64 32h53.76V896a64 64 0 0064 64h594.35a64 64 0 0064-64V277.33h55.89a32 32 0 0032-32V224a32 32 0 00-32.64-32zM789.33 874.67H237.65V277.33h551.68zM354.35 63.36h320q32 0 32 32v21.33q0 32-32 32h-320q-32 0-32-32V95.36q0-32 32-32zm260.26 364.8h21.34q32 0 32 32v251.73q0 32-32 32H614.6q-32 0-32-32V460.16q0-32 32-32zm-222.08 0h21.34q32 0 32 32v251.73q0 32-32 32h-21.34q-32 0-32-32V460.16q0-32 32-32z',
};

export function loadSvgIcon(svg: D3Element) {
  Object.keys(icons).forEach(key => {
    const iconSvg = svg
      .append('defs')
      .append('svg')
      .attr('id', 'icon-' + key)
      .attr('viewBox', '0 0 1024 1024');

    iconSvg.append('path').attr('d', icons[key]);
  });
}
